﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using NUnit.Framework;
using SQLRunnerLib.Project;
using SQLRunnerLib.Util;
using SQLTests.Framework;

namespace SQLTests.Lib.Project
{
    public class CommandLineTest : AbstractTest
    {
        #region Overrides of AbstractTest

        private LineParser Args;
        private SQLProject Project;
        private string ProjectPath;

        protected override void SetUpFixtures()
        {
            Project = ProjectTests.GetProject();
            ProjectPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"project.sqlrunner");
            var info = new FileInfo(ProjectPath);
            if (info.Exists) info.Delete();
            Project.Serialize(ProjectPath);
        }

        #endregion

        
        // Moved to SQLUnitTests

        //[Test]
        //public void Invalid_Parameter_Does_Not_Stop_Execution()
        //{
        //    var args = new string[] { "-z:Test" };
        //    Args = new LineParser(args);
        //}

        //[Test]
        //public void Connection_Details_Retrieved_From_EnvironmentSection()
        //{
        //    var projectPathArg = "-p:" + ProjectPath;
        //    var args = new string[] { projectPathArg };
        //    Args = new LineParser(args);
        //    var controller = new LineController();
        //    Assert.IsTrue(controller.TestValidateArgs(Args));
        //    Assert.IsTrue(Args.ServerName.Equals("serverName"));
        //    Assert.IsTrue(Args.DatabaseName.Equals("dbName"));
        //    Assert.IsTrue(Args.TrustedConnection);
        //}

        //[Test]
        //public void Connection_Details_Retrieved_From_CommandLine_TrustedConn()
        //{
        //    var projectPathArg = "-p:" + ProjectPath;
        //    var args = new string[] { projectPathArg, "-s:lineServer", "-d:lineDB" };
        //    Args = new LineParser(args);
        //    var controller = new LineController();
        //    Assert.IsTrue(controller.TestValidateArgs(Args));
        //    Assert.IsTrue(Args.ServerName.Equals("lineServer"));
        //    Assert.IsTrue(Args.DatabaseName.Equals("lineDB"));
        //    Assert.IsTrue(Args.TrustedConnection);
        //}

        //[Test]
        //public void Connection_Details_Retrieved_From_CommandLine_UserConn()
        //{
        //    var projectPathArg = "-p:" + ProjectPath;
        //    var args = new string[] { projectPathArg, "-s:lineServer", "-d:lineDB", "-u:username", "-w:pwd" };
        //    Args = new LineParser(args);
        //    var controller = new LineController();
        //    Assert.IsTrue(controller.TestValidateArgs(Args));
        //    Assert.IsTrue(Args.ServerName.Equals("lineServer"));
        //    Assert.IsTrue(Args.DatabaseName.Equals("lineDB"));
        //    Assert.IsTrue(!Args.TrustedConnection);
        //    Assert.IsTrue(Args.UserName.Equals("username"));
        //    Assert.IsTrue(Args.Password.Equals("pwd"));
            
        //}

    }
}
